Skip to content

[INSD-9768] Fix Channel Method Calls on Background Threads #370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 4, 2023

Conversation

a7medev
Copy link
Contributor

@a7medev a7medev commented Jul 3, 2023

Description of the change

Problem

As stated in the Flutter docs

To comply with channels’ UI thread requirement, you might need to jump from a background thread to Android’s UI thread to execute a channel method.

We have some APIs that run on a background thread either explicitly by using ThreadManager.runOnBackground or are implicitly called on a background thread by the native Android SDK.

This is the same issue we fixed in #369 for the onInvoke callback but applied to all the remaining APIs.

Solution

In order to fix this issue, all channel method calls (e.g. sending results, invoking callbacks) have been wrapped with ThreadManager.runOnMainThread.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Issue links go here

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests

Code review

  • This pull request has a descriptive title and information useful to a reviewer
  • Issue from task tracker has a link to this pull request

@a7medev a7medev requested a review from asamiz July 3, 2023 08:59
@a7medev a7medev self-assigned this Jul 3, 2023
@InstabugCI
Copy link
Collaborator

InstabugCI commented Jul 3, 2023

Coverage Report

Label Coverage Status
Dart 83.7%

Generated by 🚫 dangerJS against 4b81f30

@a7medev a7medev changed the title Fix Channel Method Calls on Background Threads [INSD-9768] Fix Channel Method Calls on Background Threads Jul 3, 2023
@a7medev a7medev marked this pull request as ready for review July 3, 2023 10:25
Copy link
Contributor

@asamiz asamiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an approval from my side, great work as usual @a7medev

@a7medev a7medev merged commit f38b3da into dev Jul 4, 2023
@a7medev a7medev deleted the fix/run-channel-methods-on-ui-thread branch July 4, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants